link-neighbors

 

link-neighbors is a turtle command that reports back the agentset of all the turtles connected that are connected to the calling turtle via links (both directed and undirected). For instance, if we were using links to represent friendship relationships, link-neighbors of turtle 3 would report back all of turtle 3's friends.

In this contact tracing model, links represent "contacts", so calling link-neighbors on an individual would report back every other person that this individual had contact with. When we implement the trace-back procedure in our code (on line 26), we ask all of the link-neighbors of any exposed (red) individuals to turn red themselves to signify that they have been exposed as well.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the link-neighbors primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Similar primitives:
neighbors

reports an agentset containing eight neighboring patches

Read more
create-links-with

creates links with every agent in an agentset

Read more
layout-circle

equally space turtles in a circle around the center of the world

Read more
 
Learn another primitive